package de.uni_mannheim.informatik.ai.dame_ai.util;

import java.awt.Dimension;
import javax.swing.JButton;

/**
 * A Button with assured minimum size.
 * @author Martin Boelle
 *
 */
@SuppressWarnings("serial")
public class MinSizeButton extends JButton {

	private static final int MIN_WIDTH=100;
	private int minWidth=MIN_WIDTH;
	
	public MinSizeButton() {
		super();
	}
	
	public MinSizeButton(int minWidth) {
		super();
		this.minWidth=minWidth;
	}
	
	public MinSizeButton(String text, int minWidth) {
		super(text);
		this.minWidth=minWidth;
	}
	
	public MinSizeButton(String text) {
		super(text);
	}
	
	
	
	@Override
	public Dimension getPreferredSize() {
		Dimension usualSize = super.getPreferredSize();
		if(usualSize.width<minWidth)
			return new Dimension(minWidth, usualSize.height);
		return usualSize;
	}
}
